﻿@model IEnumerable<BenzInfo.Hockey.Grenadiers.Models.User>
@using BenzInfo.Hockey.Grenadiers.Models

@{
    ViewBag.Title = "Index";
}

<script type="text/javascript">

    $(document).ready(function () {

        var parent = $('#user_administrator');

        $('ul', parent).disableSelection();

        $('li', parent).hover(function () {
            $('.buttons', this).show();
        }, function () {
            $('.buttons', this).hide();
        });

        $('#dialog_user').dialog({
            autoOpen: false,
            modal: true,
            draggable: false,
            resizable: false,
            width: 580,
            height: 'auto',
            buttons: [
                {
                    id: 'dialog_btn_save', text: '@BenzInfo.Hockey.Grenadiers.Resources.Dictionary.Save',
                    click: function () {
                        $('form', this).submit();
                    }
                }, 
                {
                    id: 'dialog_btn_cancel', text: '@BenzInfo.Hockey.Grenadiers.Resources.Dictionary.Cancel',
                    click: function () {
                        $(this).dialog('close');
                    }
                }
            ]
        });

        $('.buttons a', parent).click(function () {
            var url = $(this).attr('href');
            var title = '';

            if (url.indexOf('Create') > 0) {
                title = '@BenzInfo.Hockey.Grenadiers.Resources.Dictionary.Create';
                $('#dialog_btn_save span').html(title);
            }
            else if (url.indexOf('Edit') > 0) {
                title = '@BenzInfo.Hockey.Grenadiers.Resources.Dictionary.Edit';
                $('#dialog_btn_save span').html('@BenzInfo.Hockey.Grenadiers.Resources.Dictionary.Save');
            }
            else if (url.indexOf('Delete') > 0) {
                title = '@BenzInfo.Hockey.Grenadiers.Resources.Dictionary.Delete';
                $('#dialog_btn_save span').html(title);
            }

            $('#dialog_user').empty().load(url, function () {
                $('#dialog_user').dialog('option', 'title', title).dialog('open');
            });

            return false;
        });
    });

</script>

<h1>@(BenzInfo.Hockey.Grenadiers.Resources.Dictionary.User)s</h1>

<div id="dialog_user"></div>

<div id="user_administrator">
    <h2>@BenzInfo.Hockey.Grenadiers.Resources.Models.User.CategoryEnum_Administator</h2>
    @if (ViewBag.CurrentUser != null)
    { 
    	<div>
    		<span class="buttons">
    			@Html.ActionLink(BenzInfo.Hockey.Grenadiers.Resources.Dictionary.Create, "Create", new { Category = (int)BenzInfo.Hockey.Grenadiers.Models.User.CategoryEnum.Administrator })
    		</span>
    	</div>
    }<br /><br />
    @foreach (var item in Model.Where(m => m.Category == BenzInfo.Hockey.Grenadiers.Models.User.CategoryEnum.Administrator))
    {
        <div class="info">
            <b>@Html.DisplayFor(modelItem => item.FullName)</b><br />
            @BenzInfo.Hockey.Grenadiers.Resources.Models.User.DisplayUserName : @Html.DisplayFor(modelItem => item.UserName)
        </div>
        if (ViewBag.CurrentUser != null)
        {             
	        <div>
	        	<span class="buttons">
	            @Html.ActionLink(BenzInfo.Hockey.Grenadiers.Resources.Dictionary.Edit, "Edit", new { id = item.Id })
	            @Html.ActionLink(BenzInfo.Hockey.Grenadiers.Resources.Dictionary.Delete, "Delete", new { id = item.Id })
	        	</span>
	        </div>
	      }
	      <br /><br />
    }

    <div class="clear"></div>
</div>
<div style="clear:both"></div>

